package org.crspta.gohomenotes.domain;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;
import org.springframework.roo.addon.tostring.RooToString;

@RooJavaBean
@RooToString
@RooJpaActiveRecord(finders = { "findAppUsersByUsernameEquals", "findAppUsersByUsernameLike", "findAppUsersByRoles", "findAppUsersByPerson" })
public class AppUser {

    @ManyToMany(cascade = CascadeType.ALL)
    private Set<AppRole> roles = new HashSet<AppRole>();

    @ManyToOne
    private Person person;

    @NotNull
    @Size(min = 5, max = 20)
    private String username;

    @NotNull
    @Size(min = 5, max = 20)
    private String password;
}
